//
//  FinishedSubHeader.m
//  RRQS
//
//  Created by kyjun on 16/3/29.
//
//

#import "FinishedSubHeader.h"

@interface FinishedSubHeader ()

@property(nonatomic,strong) UILabel* labelOrderNO;
@property(nonatomic,strong) UILabel* labelMoney;

@end

@implementation FinishedSubHeader

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if(self){
        self.contentView.backgroundColor = [UIColor colorWithRed:255/255.f green:255/255.f blue:255/255.f alpha:1.0];
        [self layoutUI];
        [self layoutConstraints];
    }
    return self;
}

#pragma mark =====================================================  user interface layout
-(void)layoutUI{
    [self addSubview:self.labelOrderNO];
    [self addSubview:self.labelMoney];
}

-(void)layoutConstraints{
    self.labelOrderNO.translatesAutoresizingMaskIntoConstraints = NO;
    self.labelMoney.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self.labelOrderNO addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SCREEN_WIDTH*2/3]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.f]];
    
    [self.labelMoney addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SCREEN_WIDTH/3]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-10.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.f]];

    
}

#pragma mark =====================================================  property package
-(void)setEntity:(MOrder *)entity{
    if(entity){
        _entity = entity;
        self.labelOrderNO.text = [NSString stringWithFormat:@"总订单号 : %@",entity.rowID];
        self.labelMoney.text = [NSString stringWithFormat:@"计算中%@元",entity.shipFee];
    }
}

-(UILabel *)labelOrderNO{
    if(!_labelOrderNO){
        _labelOrderNO = [[UILabel alloc]init];
        _labelOrderNO.font = [UIFont systemFontOfSize:12.f];
        _labelOrderNO.textColor = [UIColor colorWithRed:135/255.f green:135/255.f blue:135/255.f alpha:1.0];
    }
    return _labelOrderNO;
}

-(UILabel *)labelMoney{
    if(!_labelMoney){
        _labelMoney = [[UILabel alloc]init];
        _labelMoney.textAlignment = NSTextAlignmentRight;
        _labelMoney.font = [UIFont systemFontOfSize:12.f];
        _labelMoney.textColor = [UIColor colorWithRed:90/255.f green:90/255.f blue:90/255.f alpha:1.0];
    }
    return _labelMoney;
}


@end
